<template>
	<view class="content">

		<view class="infoCont" v-if="list1.length">
			<view class="item" v-for="item in list1" @click="get(item)">

				<view v-if="item.status!=2" class="constents">
					<view class="top">
						<view class="label">

							<!-- 提现失败 提现成功 提现中 -->
							{{item.desc}}
							<view v-if="item.status=='1'" class="tag ">
								{{item.status_text}}
							</view>

							<view v-else-if="item.status=='3'" class="tag suc">
								{{item.status_text}}
							</view>
							<view v-else class="tag fail">
								{{item.status_text}}
							</view>
						</view>
						<view class="time">
							{{item.create_time}}
						</view>
					</view>
					<view class="bot">
						+ {{item.money}}
					</view>

				</view>
				<view v-else class="constents">
					<view class="top">
						<view class="label">

							<!-- 提现失败 提现成功 提现中 -->
							{{item.desc}}
							<view v-if="item.status=='1'" class="tag ">
								{{item.status_text}}
							</view>

							<view v-else class="tag suc">
								{{item.status_text}}
							</view>
						</view>
						<view class="time">
							{{item.create_time}}
						</view>
					</view>
					<view class="bot">
						<view class="">

							<u-tag shape="circle" text="确认收款" mode="dark" />
						</view>
						<view  style="text-align: right;">
							+ {{item.money}}
						</view>
					</view>

				</view>


			</view>
			<uni-load-more :status="status"></uni-load-more>
		</view>
		<view class="infoCont" v-else>
			<view v-if="!list1.length && senDate" class="empty" style="padding-top: 150px;">
				<view class="emptyAddress-box">
					<u-empty src="https://zzdiy-prod.oss-cn-chengdu.aliyuncs.com/zzdiy_seller/empty.png" icon-size="300"
						text="暂无数据" mode="data"></u-empty>
				</view>
			</view>
		</view>
	</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				background: {
					background: ' linear-gradient( 180deg, #ff4881 0%, #ff5d8e 21%, #fe7fa0 55%)'
				},

				total: null, //总共多少条数据
				list1: [
					// 	{
					// 	nickName: 11,
					// 	createTime: '22',
					// },
				],
				formData: {
					pageSize: 15, //每页10条数据
					page: 1, //第几页
				},
				status: "more",
				senDate: false,
				transferParams: '',
				curId: ""
			}
		},

		onReachBottom() {
			// let allTotal = this.formData.page * this.formData.pageSize;
			// if (allTotal < this.total) {
			let allTotal = this.formData.pageSize;
			if (this.total) {
				//当前条数小于总条数 则增加请求页数
				this.status = "loading"; //加载中状态
				this.formData.page++;

				this.getList();

			} else {
				this.status = "noMore"; //加载完状态
				console.log("已加载全部数据");
			}
		},


		onLoad() {
			this.getList();
		},

		methods: {
			get(item) {
				if (item.status == 2) {
					this.curId = item.id;
					this.transferParams = JSON.parse(item.pay_desc)
					this.initTransfer()
				}
				console.log(this.transferParams, 4444)
			},

			Fnsavestatus(id) {
				this.$u.api
					.savestatus({
						id
					})
					.then((res) => {
						this.formData.page = 1;
						this.list1 = []
						this.getList();
					});
			},
			initTransfer() {

				if (wx.canIUse('requestMerchantTransfer')) {
					wx.requestMerchantTransfer({
						mchId: '1710315945',
						appId: 'wxbd2e4085c4ca91df',
						package: this.transferParams.package_info,
						success: (res) => {
							this.Fnsavestatus(this.curId)
							console.log('success:', res);
						},
						fail: (res) => {
							console.log('fail:', res);
						},
					});
				} else {
					wx.showModal({
						content: '你的微信版本过低，请更新至最新版本。',
						showCancel: false,
					});
				}



			},
			change(index) {
				this.current = index;
			},

			getList() {
				this.senDate = false;
				this.$u.api
					.Withdrawrecords({
						page: this.formData.page,
						per_page: this.formData.pageSize,
					})
					.then((res) => {

						this.senDate = true;
						if (res.code == 1) {
							this.total = res?.data?.count;
							const newlist = res?.data?.list;
							this.list1.push(...newlist);
							if (this.list1.length < this.formData.pageSize) {
								this.status = "noMore"; //加载完状态
							}
						} else {
							this.status = "noMore"; //加载完状态
							console.log("请求数据失败");
						}



					});





			},



		}


	}
</script>
<style>
	page {
		background: #CBECD5;
	}
</style>
<style scoped lang="scss">
	.infoCont {
		padding: 8rpx 40rpx 40rpx;
		background: #FFFFFF;
		border-radius: 30rpx 30rpx 0 0;
		box-shadow: 0rpx 0rpx 30rpx 0rpx rgba(220, 175, 84, 0.3);
		min-height: 100vh;
	}




	.item {
		border-bottom: 1rpx solid #E0E0E0;
		padding: 30rpx 0 18rpx 8rpx;
		display: flex;
		// align-items: center;
		justify-content: space-between;
		font-size: 13px;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #ED2933;

		.constents {
			display: flex;
			align-items: center;
			justify-content: space-between;
			flex: 1;
			// margin: 14rpx 0 0 19rpx;

			.top {
				margin-bottom: 4rpx;

				.label {
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 27rpx;
					color: #333333;
					line-height: 32rpx;
					display: flex;
					align-items: center;

					.tag {
						margin-left: 13rpx;
						padding: 2rpx 15rpx;
						background: #fff;
						border-radius: 10rpx;
						border: 1rpx solid #FFAA3C;
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						font-size: 20rpx;
						color: #FF9D00;

						&.suc {
							// background: #7cac93;
							border: 1rpx solid #35AC6C;
							color: #35AC6C;
						}
						&.fail {
							// background: #7cac93;
							border: 1rpx solid #ED2933;
							color:#ED2933;
						}
						
					}
				}

				.time {
					margin-top: 8rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 300;
					font-size: 24rpx;
					color: #666666;
					line-height: 28rpx;
				}
			}

			.bot {
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 32rpx;
				color: #35AC6C;
			}
		}



	}
</style>